package aos.maekawa;

import aos.maekawa.entity.Message;
import aos.maekawa.entity.MessageType;
import aos.maekawa.entity.RoutineData;

public class MasterNode {

	private int nodeId;
	private ProcessorNode processorNode;

	public MasterNode(ProcessorNode processorNode) {
		this.processorNode = processorNode;
		this.nodeId = this.processorNode.getNodeId();
	}

	public void startAll() {
		int n = RoutineData.n;
		for (int i = 0; i < n; ++i) {
			Message msg = new Message();
			msg.setMsgType(MessageType.INIT);
			msg.setFromId(nodeId);
			msg.setToId(i);
			try {
				processorNode.sendMessage(msg);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

}
